﻿using System;
using System.Collections.Generic;

namespace Poly2Tri
{
	// Token: 0x02000406 RID: 1030
	public class TriangulationPoint : Point2D
	{
		// Token: 0x06001CB8 RID: 7352 RVA: 0x000B32BE File Offset: 0x000B14BE
		public TriangulationPoint(double x, double y) : this(x, y, TriangulationPoint.kVertexCodeDefaultPrecision)
		{
		}

		// Token: 0x06001CB9 RID: 7353 RVA: 0x000B32CD File Offset: 0x000B14CD
		public TriangulationPoint(double x, double y, double precision) : base(x, y)
		{
			this.mVertexCode = TriangulationPoint.CreateVertexCode(x, y, precision);
		}

		// Token: 0x1700041E RID: 1054
		// (get) Token: 0x06001CBA RID: 7354 RVA: 0x000B32E5 File Offset: 0x000B14E5
		// (set) Token: 0x06001CBB RID: 7355 RVA: 0x000B32ED File Offset: 0x000B14ED
		public override double X
		{
			get
			{
				return this.mX;
			}
			set
			{
				if (value != this.mX)
				{
					this.mX = value;
					this.mVertexCode = TriangulationPoint.CreateVertexCode(this.mX, this.mY, TriangulationPoint.kVertexCodeDefaultPrecision);
				}
			}
		}

		// Token: 0x1700041F RID: 1055
		// (get) Token: 0x06001CBC RID: 7356 RVA: 0x000B331E File Offset: 0x000B151E
		// (set) Token: 0x06001CBD RID: 7357 RVA: 0x000B3326 File Offset: 0x000B1526
		public override double Y
		{
			get
			{
				return this.mY;
			}
			set
			{
				if (value != this.mY)
				{
					this.mY = value;
					this.mVertexCode = TriangulationPoint.CreateVertexCode(this.mX, this.mY, TriangulationPoint.kVertexCodeDefaultPrecision);
				}
			}
		}

		// Token: 0x17000420 RID: 1056
		// (get) Token: 0x06001CBE RID: 7358 RVA: 0x000B3357 File Offset: 0x000B1557
		public uint VertexCode
		{
			get
			{
				return this.mVertexCode;
			}
		}

		// Token: 0x17000421 RID: 1057
		// (get) Token: 0x06001CBF RID: 7359 RVA: 0x000B335F File Offset: 0x000B155F
		// (set) Token: 0x06001CC0 RID: 7360 RVA: 0x000B3367 File Offset: 0x000B1567
		public List<DTSweepConstraint> Edges { get; private set; }

		// Token: 0x17000422 RID: 1058
		// (get) Token: 0x06001CC1 RID: 7361 RVA: 0x000B3370 File Offset: 0x000B1570
		public bool HasEdges
		{
			get
			{
				return this.Edges != null;
			}
		}

		// Token: 0x06001CC2 RID: 7362 RVA: 0x000B337E File Offset: 0x000B157E
		public override string ToString()
		{
			return base.ToString() + ":{" + this.mVertexCode.ToString() + "}";
		}

		// Token: 0x06001CC3 RID: 7363 RVA: 0x000B3357 File Offset: 0x000B1557
		public override int GetHashCode()
		{
			return (int)this.mVertexCode;
		}

		// Token: 0x06001CC4 RID: 7364 RVA: 0x000B33A8 File Offset: 0x000B15A8
		public override bool Equals(object obj)
		{
			TriangulationPoint triangulationPoint = obj as TriangulationPoint;
			if (triangulationPoint != null)
			{
				return this.mVertexCode == triangulationPoint.VertexCode;
			}
			return base.Equals(obj);
		}

		// Token: 0x06001CC5 RID: 7365 RVA: 0x000B33D8 File Offset: 0x000B15D8
		public override void Set(double x, double y)
		{
			if (x != this.mX || y != this.mY)
			{
				this.mX = x;
				this.mY = y;
				this.mVertexCode = TriangulationPoint.CreateVertexCode(this.mX, this.mY, TriangulationPoint.kVertexCodeDefaultPrecision);
			}
		}

		// Token: 0x06001CC6 RID: 7366 RVA: 0x000B3428 File Offset: 0x000B1628
		public static uint CreateVertexCode(double x, double y, double precision)
		{
			float value = (float)MathUtil.RoundWithPrecision(x, precision);
			float value2 = (float)MathUtil.RoundWithPrecision(y, precision);
			uint nInitialValue = MathUtil.Jenkins32Hash(BitConverter.GetBytes(value), 0U);
			return MathUtil.Jenkins32Hash(BitConverter.GetBytes(value2), nInitialValue);
		}

		// Token: 0x06001CC7 RID: 7367 RVA: 0x000B3462 File Offset: 0x000B1662
		public void AddEdge(DTSweepConstraint e)
		{
			if (this.Edges == null)
			{
				this.Edges = new List<DTSweepConstraint>();
			}
			this.Edges.Add(e);
		}

		// Token: 0x06001CC8 RID: 7368 RVA: 0x000B3488 File Offset: 0x000B1688
		public bool HasEdge(TriangulationPoint p)
		{
			DTSweepConstraint dtsweepConstraint = null;
			return this.GetEdge(p, out dtsweepConstraint);
		}

		// Token: 0x06001CC9 RID: 7369 RVA: 0x000B34A0 File Offset: 0x000B16A0
		public bool GetEdge(TriangulationPoint p, out DTSweepConstraint edge)
		{
			edge = null;
			if (this.Edges == null || this.Edges.Count < 1 || p == null || p.Equals(this))
			{
				return false;
			}
			foreach (DTSweepConstraint dtsweepConstraint in this.Edges)
			{
				if ((dtsweepConstraint.P.Equals(this) && dtsweepConstraint.Q.Equals(p)) || (dtsweepConstraint.P.Equals(p) && dtsweepConstraint.Q.Equals(this)))
				{
					edge = dtsweepConstraint;
					return true;
				}
			}
			return false;
		}

		// Token: 0x06001CCA RID: 7370 RVA: 0x000AF9A1 File Offset: 0x000ADBA1
		public static Point2D ToPoint2D(TriangulationPoint p)
		{
			return p;
		}

		// Token: 0x04001DA8 RID: 7592
		public static readonly double kVertexCodeDefaultPrecision = 5.0;

		// Token: 0x04001DA9 RID: 7593
		protected uint mVertexCode;
	}
}
